<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Pointforapi extends Model
{
    protected $table = 'pointsfor';
    public $timestamps = false;
    protected $guarded = [
        'name', 'money', 'weixin', 'ishavehouse', 'apply_time', 'updated_at', 'deleted_at'
    ];


    public function getData($id){
        $pointforList = array();
        $sql = \DB::table($this->table)
            ->whereNull('deleted_at');

        $pointforList['list'] = $sql->select('user_id','point_month','created_at','money','withdrawal_address')
            ->where('user_id', $id)
           ->get();

        return $pointforList;
    }

    public function saveData($data){
        return \DB::table($this->table)->insert($data);
    }

    //获取当前可用积分
    public function getpoint(){
        $sql = \DB::table('personInfo')
            ->whereNull('deleted_at');

        $point = $sql->select('presentPoints')
            ->where('user_id',1)
            ->get();

        return $point;
    }


    //提现后更新积分

    public function setpoint($id,$data){

        return \DB::table('personInfo')->where('user_id',$id)->update($data);

    }

}